import { request } from "./request";

export function getMenus(type) {
  return request({
    method: "get",
    url: "/permission",
    params: {
      type: type,
    },
  });
}
export function getMenusByUserId(type, uId) {
  return request({
    method: "get",
    url: `/permission/menus`,
    params: {
      type: type,
      userId: uId,
    },
  });
}
//根据id查询权限信息
export const getPermissionInfoById = (roleId) => {
  return request({
    method: "get",
    url: `/permission/${roleId}`,
  });
};

//根据id查询权限信息及菜单列表
export const getPermissionById = (roleId) => {
  return request({
    method: "get",
    url: `/permission/permissionMenus/${roleId}`,
  });
};

//根据id删除权限
export const deletePermissionsById = (ids) => {
  return request({
    method: "delete",
    url: "/permission",
    data: ids,
  });
};
//更新权限
export const updatePermission = (permission) => {
  return request({
    method: "put",
    url: "/permission",
    data: permission,
  });
};
//添加权限
export const addPermission = (permission) => {
  return request({
    method: "post",
    url: "/permission",
    data: permission,
  });
};
